// 引入同级目录下文件

export function getLangAll(): any {
  const message: any = {};
  const modules = import.meta.glob("./*", { eager: true });
  getLangFiles(modules, message);
  return message;
}
/**
 * 获取所有语言文件
 * @param {Object} mList
 */
function getLangFiles(mList: any, msg: any) {
  for (let path in mList) {
    if (mList[path].default) {
      //  获取文件名
      const before = path.lastIndexOf("/") + 1;
      const after = path.lastIndexOf(".");
      let pathName = path.slice(before, after);

      if (msg[pathName]) {
        msg[pathName] = {
          ...mList[pathName],
          ...mList[path].default,
        };
      } else {
        msg[pathName] = mList[path].default;
      }
    }
  }
}
